﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using 聚欣订单分析.PublicClass;
using 聚欣订单分析.Ling;

namespace 聚欣订单分析
{
    public partial class kpsh : System.Web.UI.Page
    {
        PLSQLClass PL = new PLSQLClass();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 通过
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            List<object> keyValues = this.ASPxGridView1.GetSelectedFieldValues("ID");
            List<object> DDID = this.ASPxGridView1.GetSelectedFieldValues("DDID");
            if (keyValues.Count > 0)
            {
                for (int i = 0; i < keyValues.Count; i++)
                {
                    string strSQL1 = "update tbl_DDB set 开票='已开',状态='开票通过' where ID=" + DDID[i].ToString();
                    string strSQL2 = "update tbl_KPSH set zt=1,BZ='" + ASPxMemo1.Text.Trim() + "' where ID=" + keyValues[i].ToString();
                    PL.ExecuteSqlWithGoUseTran(strSQL1 + "go" + strSQL2);
                }
                JsHelper.AlertAndRedirect("审核成功", "kpsh.aspx");
                
            }
            else
            {
                JsHelper.Alert("请选择订单！");
            }
        }

        /// <summary>
        /// 回退
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void bthTh_Click(object sender, EventArgs e)
        {
            List<object> keyValues = this.ASPxGridView1.GetSelectedFieldValues("ID");
            List<object> DDID = this.ASPxGridView1.GetSelectedFieldValues("DDID");
            if (keyValues.Count > 0)
            {
                for (int i = 0; i < keyValues.Count; i++)
                {
                    string strSQL1 = "update tbl_DDB set 开票='未开',状态='开票回退',开票金额=0 where ID=" + DDID[i].ToString();
                    string strSQL2 = "update tbl_KPSH set zt=2,BZ='" + ASPxMemo1.Text.Trim() + "' where ID=" + keyValues[i].ToString();
                    PL.SqlGetData(strSQL1);
                    PL.SqlGetData(strSQL2);
                }
                JsHelper.AlertAndRedirect("审核成功", "kpsh.aspx");
            }
            else
            {
                JsHelper.Alert("请选择订单！");
            }
        }
    }
}
